package com.gitee.simons.common.tree;

import com.gitee.simons.common.utils.GsonUtil;
import lombok.AllArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jsm
 * @date 2018/12/12 18:23
 * @Description
 */
@AllArgsConstructor
public class TreeDemo extends StrTreeModel {

    public static void main(String[] args) {
        TreeDemo strTreeModel1 = new TreeDemo();
        strTreeModel1.setId("e");
        strTreeModel1.setName("asdasd");
        strTreeModel1.setParentId("");
        TreeDemo strTreeModel2 = new TreeDemo();
        strTreeModel2.setId("a");
        strTreeModel2.setName("asdasd");
        strTreeModel2.setParentId("e");
        TreeDemo strTreeModel3 = new TreeDemo();
        strTreeModel3.setId("b");
        strTreeModel3.setName("asdasd");
        strTreeModel3.setParentId("e");
        TreeDemo strTreeModel4 = new TreeDemo();
        strTreeModel4.setId("c");
        strTreeModel4.setName("asdasd");
        strTreeModel4.setParentId("e");

        List<TreeDemo> treeList = new ArrayList<TreeDemo>();
        treeList.add(strTreeModel1);
        treeList.add(strTreeModel2);
        treeList.add(strTreeModel3);
        treeList.add(strTreeModel4);
        String json = GsonUtil.gson.toJson(StrTreeBuilder.model2Tree(treeList));
        System.out.println(json);
    }
}
